<?php
namespace app\admin\controller\system;
use app\common\annotation\NodeAnnotation;
use app\common\controller\Admin;
use app\common\traits\ControllerCurd;
use think\Request;
/**
 * @package app\admin\controller\system
 * @NodeAnnotation(
 *     title="系统Debug",
 *     is_menu=0,
 *     is_view=0
 * )
 */
class Debug extends Admin
{
    use ControllerCurd;
    public $model;

    public function initialize()
    {
        parent::initialize();
        $this->model= new \app\admin\model\system\Debug();
    }

    /**
     * @NodeAnnotation(
     *     title="bug/建议/需求",
     *     parent="admin/system.debug",
     *     MenuRoot="admin/system.setting"
     * )
     */
    public function index()
    {
        $this->assign([
            "debugList" => $this->model->order("create_time desc")->paginate()
        ]);
        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="添加debug",
     *     parent="admin/system.debug",
     *     MenuRoot="admin/system.setting",
     *     is_menu=0
     * )
     */
    public function adddebug(Request $request)
    {
        $this->add(url('admin/system.debug/index'));

        $this->assign([
            "debugType" => $request->param("debugType",0,'intval')
        ]);
        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="编辑debug",
     *     parent="admin/system.debug",
     *     MenuRoot="admin/system.setting",
     *     is_menu=0
     * )
     */
    public function editdebug(Request $request,$id=0)
    {
        $this->edit(url('admin/system.debug/index'));
        $this->assign([
            "debug"   =>  $this->model->findData($id),
        ]);
        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="删除debug",
     *     parent="admin/system.debug",
     *     MenuRoot="admin/system.setting",
     *     is_view=0,
     *     is_menu=0
     * )
     */
    public function deldebug(Request $request)
    {
        $this->del();
    }

}